package stats;

import java.util.Map;
import java.util.TreeMap;

/**
 * 
 * @author Yin
 *
 */
public abstract class AbstractOperationStats implements IStats
{
	private Map<String, Object> myResults;
	
	public AbstractOperationStats()
	{
		myResults = new TreeMap<String, Object>();
	}
	
	/**
	 * Add new statistic associating with an event.
	 */
	public abstract void addStat(String eventName);
	
	/**
	 * Define operation for updating statistical resultss
	 * @param eventName
	 */
	public abstract void setOperation(String eventName);
	
	/**
	 * Define initial values for statistics
	 * @param eventName
	 */
	public abstract void setInitialStat(String eventName);
	
	/**
	 * Get statistical result for given event
	 * @param eventName
	 * @return
	 */
	public abstract Object getResult(String eventName);
	
	/**
	 * Get all statistical result
	 * @return
	 */
	public Map<String, Object> getResults()
	{
		return myResults;
	}
	
	/**
	 * Return true if the event is already registered for statistics.
	 * @param eventName
	 * @return
	 */
	public boolean isEventExist(String eventName)
	{
		return myResults.containsKey(eventName);
	}
	
	/**
	 * Save all statistics to file
	 */
	public abstract void save();
	
	/**
	 * Load all statistics from a file
	 */
	public abstract void load(String location);
}
